package com.example.model;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

public class Contacts   implements Parcelable {
	/*"id":"1",
    "owner":"1",
    "gender":"male",
    "first_name":"a1",
    "last_name":"a1",
    "phone_number":"24234234",
    "email":"sdfsdf@sdf.sadf",
    "website":"skjdfaksjf",
    "country":"kajshf",
    "state":"kjasdf",
    "postcode":"kja sf kajsdf",
    "city":"k ajsdfha ksjdf",
    "address":"a ksdjfh aksf",
    "company":"kaj sdfh aksf",
    "birthday":"kja sdhfkaj f",
    "avatar":"aksjdf haskdjf",
    "more_info":" kjasdf"},*/
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String id;
	private String owner;
	private String gender;
	private String firstName;
	private String lastName;
	private String phoneNumber;
	private String email;
	private String website;
	private String country;
	private String state;
	private String postCode;
	private String city;

	private String address;
	private String company;
	private String birthday;
	private String avatar;
	private String moreInfo;
	private int status = 0;
	
	public Contacts(){
		
	}
	
	//(new Contacts(name, id, email, birthday, phone, rand.nextInt(3), uri1));
	public Contacts(String firstname, String lastname,String id,String email,String birthday,String phone,int ower,String avatar, String address){
		this.id = id;
		this.email = replaceNull(email); 
		this.firstName = replaceNull(firstname);
		this.lastName =  replaceNull(lastname);
		this.birthday = replaceNull(birthday);
		this.phoneNumber = replaceNull(phone);
		this.owner  = String.valueOf(ower);
		this.avatar = replaceNull(avatar);
		this.address = replaceNull(address);
		
	}
	public Contacts(Parcel in) 
	{
		readFromParcel(in);
	} 
	
	
	private String replaceNull(String value)
	{
		if(!TextUtils.isEmpty(value) && value.contains("null") && value.equalsIgnoreCase("null") && value.length()<=4)
			return value.replace("null", "");
		else if(TextUtils.isEmpty(value))
			return "";
		return value;
	}
	
	@Override
	public String toString() {
		return "Contacts [id=" + id + ", owner=" + owner + ", gender=" + gender
				+ ", firstName=" + firstName + ", lastName=" + lastName
				+ ", phoneNumber=" + phoneNumber + ", email=" + email
				+ ", website=" + website + ", country=" + country + ", state="
				+ state + ", postCode=" + postCode + ", city=" + city
				+ ", address=" + address + ", company=" + company
				+ ", birthday=" + birthday + ", avatar=" + avatar
				+ ", moreInfo=" + moreInfo + "]";
	}

	public Contacts(String name,String id,String birthday,String phone,int ower,String avatar){
		this.firstName = name;
		this.id = String.valueOf(id);
		this.birthday = birthday;
		this.phoneNumber = phone;
		this.owner  = String.valueOf(ower);
		this.avatar = avatar;
		
	}
	/**
	 * @return the id
	 */
	public String getId() {
		return id;
	}
	/**
	 * @param id the id to set
	 */
	public void setId(String id) {
		this.id = id;
	}
	/**
	 * @return the owner
	 */
	public String getOwner() {
		return owner;
	}
	/**
	 * @param owner the owner to set
	 */
	public void setOwner(String owner) {
		this.owner = owner;
	}
	/**
	 * @return the firstName
	 */
	public String getFirstName() {
		return firstName;
	}
	/**
	 * @param firstName the firstName to set
	 */
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}
	/**
	 * @return the lastName
	 */
	public String getLastName() {
		return lastName;
	}
	/**
	 * @return the gender
	 */
	public String getGender() {
		return gender;
	}
	/**
	 * @param gender the gender to set
	 */
	public void setGender(String gender) {
		this.gender = gender;
	}
	/**
	 * @param lastName the lastName to set
	 */
	public void setLastName(String lastName) {
		this.lastName = lastName;
	}
	/**
	 * @return the phoneNumber
	 */
	public String getPhoneNumber() {
		return phoneNumber;
	}
	/**
	 * @param phoneNumber the phoneNumber to set
	 */
	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumber = phoneNumber;
	}
	/**
	 * @return the email
	 */
	public String getEmail() {
		return email;
	}
	/**
	 * @return the website
	 */
	public String getWebsite() {
		return website;
	}
	/**
	 * @param website the website to set
	 */
	public void setWebsite(String website) {
		this.website = website;
	}
	/**
	 * @param email the email to set
	 */
	public void setEmail(String email) {
		this.email = email;
	}
	/**
	 * @return the country
	 */
	public String getCountry() {
		return country;
	}
	/**
	 * @param country the country to set
	 */
	public void setCountry(String country) {
		this.country = country;
	}
	/**
	 * @return the state
	 */
	public String getState() {
		return state;
	}
	/**
	 * @param state the state to set
	 */
	public void setState(String state) {
		this.state = state;
	}
	/**
	 * @return the postCode
	 */
	public String getPostCode() {
		return postCode;
	}
	/**
	 * @param postCode the postCode to set
	 */
	public void setPostCode(String postCode) {
		this.postCode = postCode;
	}
	/**
	 * @return the city
	 */
	public String getCity() {
		return city;
	}
	/**
	 * @param city the city to set
	 */
	public void setCity(String city) {
		this.city = city;
	}
	/**
	 * @return the address
	 */
	public String getAddress() {
		return address;
	}
	/**
	 * @param address the address to set
	 */
	public void setAddress(String address) {
		this.address = address;
	}
	/**
	 * @return the company
	 */
	public String getCompany() {
		return company;
	}
	/**
	 * @param company the company to set
	 */
	public void setCompany(String company) {
		this.company = company;
	}
	/**
	 * @return the birthday
	 */
	public String getBirthday() {
		return birthday;
	}
	/**
	 * @param birthday the birthday to set
	 */
	public void setBirthday(String birthday) {
		this.birthday = birthday;
	}
	/**
	 * @return the avatar
	 */
	public String getAvatar() {
		return avatar;
	}
	/**
	 * @param avatar the avatar to set
	 */
	public void setAvatar(String avatar) {
		this.avatar = avatar;
	}
	/**
	 * @return the moreInfo
	 */
	public String getMoreInfo() {
		return moreInfo;
	}
	/**
	 * @param moreInfo the moreInfo to set
	 */
	public void setMoreInfo(String moreInfo) {
		this.moreInfo = moreInfo;
	}

	public int getStatus() {
		return  status;
	}
	public void setStatus(int status) {
		this.status  = status;
		
	}
	public void setStatus(String status) {
		try{
			this.status  = Integer.parseInt(status);
		}catch(Exception e){
			this.status  = 0;
		}
		
		
		
	}
	@Override 
	public void writeToParcel(Parcel dest, int flags) 
	{   
		dest.writeString(id);
		dest.writeString(owner);
		dest.writeString(gender);
		dest.writeString(firstName);
		dest.writeString(lastName);
		dest.writeString(phoneNumber);
		dest.writeString(email);
		dest.writeString(website);
		dest.writeString(country);
		dest.writeString(state);
		dest.writeString(postCode);
		dest.writeString(city);

		dest.writeString(address);
		dest.writeString(company);
		dest.writeString(birthday);
		dest.writeString(avatar);
		dest.writeString(moreInfo);
		
	 } 
	private void readFromParcel(Parcel in) {  
		id = in.readString();
		owner = in.readString();
		gender = in.readString();
		firstName = in.readString();
		lastName = in.readString();
		phoneNumber = in.readString();
		email= in.readString();
		website= in.readString();
		country = in.readString();
		state = in.readString();
		postCode = in.readString();
		city = in.readString();

		address = in.readString();
		company = in.readString();
		birthday = in.readString();
		avatar = in.readString();
		moreInfo =  in.readString();
		
		}

	@Override
	public int describeContents() {
		// TODO Auto-generated method stub
		return 0;
	} 
		
	public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { 
		public Contacts createFromParcel(Parcel in) 
		  { 
			return new Contacts(in); 
		  }  
		public Contacts[] newArray(int size) 
		{ return new Contacts[size];
		} 
		}; 
		
}
	
	


